home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-10-06 | 3.8 KB | 149 lines | [TEXT/CWIE] |
- ///--------------------------------------------------------------------------------------
- // SWApplication.c
- //
- // Portions are Copyright: © 1993 Tony Myles, All rights reserved worldwide.
- ///--------------------------------------------------------------------------------------
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __SPRITEWORLD__
- #include <SpriteWorld.h>
- #endif
-
- #include <Gestalt.h>
- #include <Fonts.h>
- #include <TextUtils.h>
- #include <SWApplication.h>
-
-
- ///--------------------------------------------------------------------------------------
- // Initialize
- ///--------------------------------------------------------------------------------------
-
- void Initialize(short numberOfMasters)
- {
- EventRecord tempEvent;
-
- MaxApplZone();
-
- while (numberOfMasters--)
- {
- MoreMasters();
- }
-
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NULL);
- InitCursor();
- FlushEvents(everyEvent, 0);
-
- (void)EventAvail(everyEvent, &tempEvent);
- (void)EventAvail(everyEvent, &tempEvent);
- (void)EventAvail(everyEvent, &tempEvent);
- }
-
-
- ///--------------------------------------------------------------------------------------
- // ReportError
- ///--------------------------------------------------------------------------------------
-
- void ReportError(OSErr err, char* filename, int lineNumber)
- {
- SetCursor(&qd.arrow);
- InitCursor();
-
- if (err == memFullErr)
- {
- ErrorAlert(err, filename, lineNumber, kOutOfMemoryStringIndex);
- }
- else if (err == resNotFound)
- {
- ErrorAlert(err, filename, lineNumber, kCantFindResourceStringIndex);
- }
- else
- {
- ErrorAlert(err, filename, lineNumber, kFatalErrorStringIndex);
- }
- }
-
-
- ///--------------------------------------------------------------------------------------
- // DoCantFindResource
- ///--------------------------------------------------------------------------------------
-
- void DoCantFindResource( char* filename, int lineNumber )
- {
- OSErr err;
-
- err = ResError();
-
- if (err == noErr)
- err = MemError();
-
- // It's annoying that some toolbox functions, such as GetPicture, don't give
- // ResError OR MemError an error code, nor does the function return any error value. So
- // you know it failed, but you don't know why. So DoCantFindResource might report
- // a resNotFound error when the resource really does exist, but there simply isn't
- // enough memory to load it.
- if (err == noErr)
- err = resNotFound;
-
- ErrorAlert(err, filename, lineNumber, kCantFindResourceStringIndex);
- }
-
-
- ///--------------------------------------------------------------------------------------
- // ErrorAlert
- ///--------------------------------------------------------------------------------------
-
- void ErrorAlert(OSErr err, char* filename, int lineNumber, short errorStringIndex)
- {
- Str255 messageString, errorString, fileString = "\p", lineString;
- short n;
-
- GetIndString(messageString, kErrorStringListResID, errorStringIndex);
-
- if (messageString[0] == 0)
- {
- BlockMove(kSeriousDamageString, messageString, sizeof(kSeriousDamageString));
- }
-
- for (n = 0; filename[n] != 0; n++)
- {
- fileString[n+1] = filename[n];
- }
- fileString[0] += n;
-
- NumToString(err, errorString);
- NumToString(lineNumber, lineString);
- ParamText(messageString, fileString, lineString, errorString);
-
- // Call the CleanUpCallBack if there is one.
- if (gSWCleanUpCallBackP != NULL)
- (*gSWCleanUpCallBackP)();
-
- InitCursor();
- (void)StopAlert(kErrorAlertResID, NULL);
-
- // If a CleanUpSpriteWorld is installed, turns its VBL Syncing off.
- if (gSWCleanUpSpriteWorldP != NULL)
- SWSyncSpriteWorldToVBL(gSWCleanUpSpriteWorldP, false);
-
- ExitToShell();
- }
-
-
- ///--------------------------------------------------------------------------------------
- // CantRunOnThisMachine
- ///--------------------------------------------------------------------------------------
-
- void CantRunOnThisMachine( void )
- {
- (void)StopAlert(kCantRunAlertResID, NULL);
- }
-
-